<?php
/**
 * Created by PhpStorm.
 * User: hebidu
 * Date: 15/12/28
 * Time: 11:29
 */

namespace Api\Controller;


use Shop\Api\RedEnvelopeApi;
use Shop\Model\RedEnvelopeModel;

/**
 * 红包接口
 * Class RedEnvelopeController
 * @author 老胖子-何必都 <hebiduhebi@126.com>
 * @package Api\Controller
 */
class RedEnvelopeController extends ApiController {

    /**
     * 获取用户未使用的红包
     *
     */
    public function index(){
        $uid = $this->_post('uid','','缺少uid参数');
        $curpage = $this->_post('curpage',0);
        $curpage = intval($curpage);


        $page = array('curpage'=>$curpage,'size'=>20);
        $map = array(
            'uid'=>$uid,
        );
        $order = 'dtree_type desc,get_time desc';
        $result = apiCall(RedEnvelopeApi::API_QUERY,array($map,$page,$order));
        $data = array();
        if(!$result['status']){
            $this->apiReturnErr($result['info']);
        }

        if($result['status'] && is_array($result['info'])){
            $data = $result['info'];
        }

        if(!is_array($data['list'])){
            $data['list'] = array();
        }

        $this->apiReturnSuc($data);
    }

}